<template>
  <div class="">
    <div v-html="content" class="content"></div>
    <van-action-bar>
      <van-action-bar-icon icon="chat-o" text="客服" color="#ee0a24" />
      <van-action-bar-icon icon="cart-o" text="购物车" />
      <van-action-bar-icon icon="star" text="已收藏" color="#ff5000" />
      <van-action-bar-button type="warning" @click="add" text="加入购物车" />
      <van-action-bar-button type="danger" text="立即购买" />
    </van-action-bar>
  </div>
</template>

<script>
import { ref, reactive, toRefs } from "vue";
import { useStore } from "vuex";
import { useRouter, useRoute } from "vue-router";
import { getDetail } from "../utils/yx";
export default {
  setup(props, ctx) {
    const store = useStore();
    const router = useRouter();
    const route = useRoute();
    const data = reactive({
      content: [],
      info: "",
    });
    const id = route.params.id;
    getDetail(id).then((res) => {
      console.log(res);
      data.content = res.data.content;
      data.info = res.data.basicInfo;
    });

    const add = () => {
      store.commit("add", data.info);
    };
    //添加购物车
    return { ...toRefs(data), add };
  },
};
</script>

<style lang="scss">
.content {
  img {
    width: 100% !important;
    height: 200px !important;
  }
}

.van-action-bar {
  bottom: 50px !important;
}
</style>
